<!--
 * @Author: 祝肖 1738052358@qq.com
 * @Date: 2024-03-27 14:00:44
 * @LastEditTime: 2024-06-04 17:24:56
 * @LastEditors: 祝肖 1738052358@qq.com
 * @Description: 信用等级评定
 * @FilePath: \zmglpt-ui-mobile-v1.1\dev\pages\query\creditLvAssess\components\levelAssess.vue
 * 可以输入预定的版权声明、个性签名、空行等
-->
<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :isWhite="false" backText="返回" :title="navTitle"></theme-navbar>
    <!-- #endif -->
    <view class="assess-page">
      <!-- 列表内容 -->
      <view class="card card-content">
        <view class="top-title">
          <img src="@/static/market/levelAssessTitle.png" class="top-img" />
          {{companyName}}
          <span class="top-hirEval" @click="goHitoryRval">{{ '历史评定>>' }}</span>
        </view>
        <view class="top-content">
          <!-- 黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18 -->
          <view :class="[isHasFile ? 'HasFile' : 'dotHasFile', 'zk-img-content'] " @click="viewFlies">

            <!-- <m-upload
             style="opacity:0;"
                :deletable="false"
                :maxCount="picIds"
                width="150rpx"
                height="150rpx"
                :file-list="fileList"
                :multiple="true"
                index="fileList"
                :uploadParam="{'fiGroupCode':$FILE_GROUP_TYPE.m_check_attr, }"
                upApiUrl="uploadBase64ForApp"
                ref="filePicUpload"
                @on-list-change="changeUpload"
              ></m-upload> -->
          </view>
          <view class="cont-txt">
            <view class="cont txt-wen">信用等级</view>
            <view class="cont txt-val">{{lists.creditLevel||'--'}}</view>
          </view>
          <view>
            <view class="cont txt-wen">信用分值</view>
            <view class="cont txt-val">{{lists.creditScore||'--'}}</view>
          </view>
        </view>
        <!-- 黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18 -->
        <view class="footer-content">
          <view class="fot-arr" :index="index" v-for="(item,index) in lists.targetTypeList" :key="item.key" @click="gridClick(index,item)">
            <view class="footer-txt">
              <view>
                <img :src="getUrl(index)" class="top-img" />
              </view>
              <view>
                <view class="foot txt-wen">{{item.targetTypeName}}</view>
                <view class="foot txt-val">
                  <span class="lvtxt">{{item.addScore}}</span>
                  /{{item.maxValue}}
                </view>
              </view>
            </view>
          </view>
        </view>
      </view>
      <view class="card card-content" style="padding:20px">
        <view class="top-title">
          <img :src="getUrl(cellIndex)" class="top-img" />
          {{dataObject.targetTypeName}}&nbsp;&nbsp;&nbsp;{{dataObject.addScore||0}}/{{dataObject.maxValue||0}}
        </view>
        <view class="fot-arr1" :index="index" v-for="(item,index) in listsArr" :key="item.key">
          <view class="sub-title" @click="editBtn(item)">
            <view>{{item.targetName}}</view>
            <view>得分：{{item.addScore?item.addScore:0}}</view>
          </view>
          <view :index="j" v-for="(cell,j) in item.standardList" :key="cell.key" class="cell-txt">{{j+1}}.{{cell.standardName}}</view>
        </view>
      </view>
    </view>
    <!-- 查看图片 -->
    <u-popup mode="bottom" height="35%" v-model="GoFileShow" :closeable="true">
      <view class="zk-img-content" v-if="fileList.length">
        <swiper :style="{ 'height': height + 'px','width': width + 'px' }" :indicator-dots="true" indicator-color="rgba(0,0,0,0.3)" indicator-active-color="#2979FF" :autoplay="false" :interval="interval"
          :duration="duration" @change="swiperChange">
          <swiper-item v-for="(item,index) in fileList" :key="index" >
            <image class="m-preview-image" :src="getAkAppendImg(item)"></image>
          </swiper-item>
        </swiper>
      </view>
      <view v-else class="no-file">暂未上传图片，请至电脑端上传！</view>
    </u-popup>
  </view>
</template>

<script>
import meTable from "@/components/me-table.vue";
// 黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18
import mUpload from "@/components/m-upload.vue";
import MescrollMoreMixin from "@/components/mescroll-uni/mixins/mescroll-more.js";
import checkService from "@/service/check/check.service.js";
import { C_STORE_CHECK_STATUS } from "@/service/store/mapping/enum.js";
import moment from "moment";
import { PATHROOT } from "@/common/path.config";
//  黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18
import intelligenceservice from "@/service/intelligence/intelligence.service";

const sysCodeColors = {
  "03": {
    color: "#01A79A",
    borderColor: "#01A79A",
    backgroundColor: "#C0ECE2"
  },
  "04": {
    color: "#AC0000",
    borderColor: "#AC0000",
    backgroundColor: "#F2CCCC"
  },
  "01": {
    color: "#0079F2",
    borderColor: "#0079F2",
    backgroundColor: "#E0ECFF"
  },
  "02": {
    color: "#EC7C37",
    borderColor: "#EC7C37",
    backgroundColor: "#FBE2D3"
  }
};
export default {
  //  黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18
  components: { mUpload },
  mixins: [MescrollMoreMixin],
  data() {
    return {
      user: this.$store.state.userInfo,
      fileViewUrl: PATHROOT.BASE + "/commonfile/filestore/downloadFile.do",
      // height: this.$u.sys().windowHeight - 70,
      height: 310,
      width: this.$u.sys().windowWidth,
      interval: 5000,
      duration: 500,
      GoFileShow: false,
      licNo: "",
      urlSrc: require("@/static/market/HLJ/assess1.png"),
      cellIndex: 0,
      companyName: "",
      // 黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18
      fileList: [],
      picIds: "1",
      isHasFile: false,
      isSaveFile: true,
      // 黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18
      dataObject: {
        targetType: "",
        targetTypeName: "",
        addScore: "",
        maxValue: ""
      },
      lists: {
        retailerUuid: "",
        companyName: "京东便利店（新一格店）",
        creditLevel: "AAA",
        creditScore: "99",
        targetTypeList: [
          //   { targetTypeName: "守信经营", addScore: "3", maxValue: "9" },
        ]
      },
      listsArr: [
        {
          name: "守信经营",
          val: "3",
          cont: [
            "1.六个月内没有发生无故退货行为的，加3分;",
            "2.六个月内发生无故退货行为的，不加分。"
          ]
        },
        {
          name: "合同履行",
          val: "3",
          cont: [
            "1.规范使用烟草公司配置的设施设备及终端物料的，加3分",
            "2.恶意损坏、故意闲置或擅自处置烟草公司配置的柜台、双屏机、卷烟推进器等设施设备及终端物料的不加分;"
          ]
        },
        { name: "诚信经营", val: "11", cont: ["3.无评价记录的，加3分。"] }
      ]
    };
  },
  onLoad(options) {
    this.companyName = options.companyName;
    this.lists.creditLevel = options.creditLevel;
    this.lists.creditScore = options.creditScore;
    this.lists.retailerUuid = options.retailerUuid;
    this.licNo = options.licNo;
  },
  mounted() {
    this.$nextTick(() => {
      this.getTop();
      this.getData();
      // 黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18
      this.getFileList();
      // 黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18
    });
    this.fileViewUrl += "?tk=" + this.user.tk + "&fileId=";
  },
  methods: {
    // 黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18
    getCurDate() {
      return moment().format("YYYY-MM-DD");
    },
    // 黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18
    getTop() {
      this.$u.getRect(".invent-content").then(res => {
        this.isTop = res.height + res.height - 10;
      });
    },
    getData() {
      // this.$modal.showLoading('请稍后...');
      checkService
        .getCreditInspireInfo({ retailerUuid: this.lists.retailerUuid })
        .then(res => {
          if (res.success) {
            // this.$modal.hideLoading();
            this.lists = res.bean;
            this.dataObject.maxValue = res.bean.targetTypeList[0].maxValue;
            this.dataObject.addScore = res.bean.targetTypeList[0].addScore;
            this.dataObject.targetTypeName =
              res.bean.targetTypeList[0].targetTypeName;
            this.dataObject.targetType = res.bean.targetTypeList[0].targetType;
            console.log();
            this.gridClick(0, this.dataObject);
          }
        });
    },
    gridClick(index, item) {
      this.$modal.showLoading("请稍后...");
      this.cellIndex = index;
      this.dataObject.targetTypeName = item.targetTypeName;
      this.dataObject.addScore = item.addScore;
      this.dataObject.maxValue = item.maxValue;
      console.log(item);
      this.listsArr = [];
      checkService
        .getCreditInspireList({
          targetType: item.targetType,
          retailerUuid: this.lists.retailerUuid
        })
        .then(res => {
          if (res.success) {
            this.$modal.hideLoading();
            console.log(
              res.data.some(
                v =>
                  v.targetUuid === "HL10000007" || v.targetUuid === "HL10000015"
              ),
              "someeeeee"
            );
            // 诚信经营-交易数据处理
            if (
              res.data.some(
                v =>
                  v.targetUuid === "HL10000007" || v.targetUuid === "HL10000015"
              )
            ) {
              res.data.forEach(el => {
                if (el.targetUuid === "HL10000007") {
                  let _obj = el;
                  _obj.standardList = this.trasDataMerge(res.data);
                  _obj.maxValue = this.trasMaxValueMerge(res.data);
                  this.listsArr.push(_obj);
                } else if (el.targetUuid === "HL10000015") {
                  console.log("过滤了HL10000015");
                } else {
                  this.listsArr.push(el);
                }
              });
            } else {
              this.listsArr = res.data;
            }
          }
        });
    },
    // 处理交易数据中-数据对接客户新增数据合并  xue start  2024-05-15
    trasDataMerge(list) {
      const _arr = [];
      list.forEach(v => {
        if (v.targetUuid === "HL10000007" || v.targetUuid === "HL10000015") {
          _arr.push(...v.standardList);
        }
      });
      return _arr;
    },
    trasMaxValueMerge(list){
      let _MAX=0
      list.forEach(v => {
        if (v.targetUuid === "HL10000007" || v.targetUuid === "HL10000015") {
          _MAX += Number(v.maxValue)
        }
      });
      return _MAX;
    },
    // 黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18
    //获取图片
    getFileList() {
      checkService
        .queryCreditCommitmentSign({ retailerUuid: this.lists.retailerUuid })
        .then(res => {
          if (res.bean?.signId) {
            let params = {
              bizId: res.bean.signId,
              // group: this.$FILE_GROUP_TYPE.m_check_attr,
              menuCode: null
            };
            intelligenceservice.findFilesByBizIdAndGroup(params).then(res => {
              if (res.data) {
                this.isHasFile = true;
                this.fileList = res.data;
                this.isSaveFile = false;
              }
            });
          } else {
            this.isHasFile = false;
            this.isSaveFile = true;
          }
        });
    },
    //查看图片
    viewFlies() {
      this.GoFileShow = true;
    },
    getAkAppendImg(item) {
      console.log('数据' + JSON.stringify(item))
      if (item.gfUrl) {
        return item.gfUrl;
      }
      return this.fileViewUrl + item.gfiId;
    },
    // 上传/删除图片事件
    // changeUpload(list, key) {
    //   console.log(list)
    //   if (list.length > 0) {
    //     this.fileList = [...list];
    //     if(this.isSaveFile){
    //       let uploadForm={
    //         signDate:this.getCurDate(),
    //         versions:'1'
    //       }
    //       checkService.natureRepairSavePicture({retailerUuid:this.lists.retailerUuid,fileList: this.fileList,...uploadForm}).then(res=>{
    //           if(res.success){
    //             this.isHasFile=true
    //             console.log("上传成功！")
    //             // this.$u.success("上传成功！");
    //           }
    //         })
    //     }

    //   } else {
    //     this.fileList = [];
    //     this.isHasFile=false
    //   }
    // },
    // 黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18
    getUrl(index) {
      switch (index) {
        case 0:
          return require("@/static/market/HLJ/assess1.png");
          break;
        case 1:
          return require("@/static/market/HLJ/assess2.png");
          break;
        case 2:
          return require("@/static/market/HLJ/assess3.png");
          break;
        case 3:
          return require("@/static/market/HLJ/assess4.png");
          break;
        case 4:
          return require("@/static/market/HLJ/assess5.png");
          break;
        case 5:
          return require("@/static/market/HLJ/assess6.png");
          break;
        default:
          return require("@/static/market/HLJ/assess1.png");
          break;
      }
    },
    editBtn(item) {
      if (item.targetUuid === "HL10000001") return; // 守法经营禁止跳转处理 xue start 2024-05-15
      this.$u.route("pages/query/creditLvAssess/components/levelAssessEdit", {
        retailerUuid: this.lists.retailerUuid,
        targetUuid: this.targetUuidCalc(item.standardList),
        maxValue: item.maxValue
      });
    },
    // targetUuid传递取值
    targetUuidCalc(list) {
      let _str = "";
      list.forEach(v => {
        if (_str) {
          if (!_str.includes(v.targetUuid)) _str = _str + "," + v.targetUuid;
        } else {
          _str = v.targetUuid;
        }
      });
      return _str;
    },
    // 历史评定跳转事件 xue start 2024-04-28
    goHitoryRval() {
      // this.$u.route('pages/query/creditLvAssess/components/historyEvalDetail', {
      //   retailerUuid: this.lists.retailerUuid
      // })
      this.$u.route("pages/query/creditLvAssess/components/historySwiper", {
        retailerUuid: this.lists.retailerUuid,
        licNo: this.licNo
      });
    },
    // 新增来源登记返回操作
    updateBackState(params) {
      if (params.refreshBack) {
        // this.gridClick(0, this.dataObject);
        this.getData();
      }
    }
  }
};
</script>

<style lang="scss" scoped>
// @import "./inven_common.scss";
/deep/ .uni-input-input {
  top: -20rpx;
}
.page {
  padding: 0;
}
.fs-title {
  font-weight: bold;
  font-size: 32rpx;
}
.no-file {
  display: flex;
  justify-content: center;
  padding: 20px 0;
  font-size: 32rpx;
  color: red;
}
// 黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18   不要删除 不要删除 不要删除
.zk-img-content {
  width: 100px;
  height: 92px !important;
}
.HasFile {
  background-image: url(../../../../static/check/cnsy.png);
  // z-index: 999;
  background-repeat: round;
  background-size: cover;
  overflow: hidden;
}
.dotHasFile {
  background-image: url(../../../../static/check/cnsn.png);
  background-repeat: round;
  background-size: cover;
  // z-index: 999;
}
.m-preview-image {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 10rpx;
}
// 黑龙江-信用评定-增加上传承诺书功能  zx start  2024-04-18  不要删除 不要删除 不要删除
.assess-page {
  .card-content {
    padding: 10px;
    .top-title {
      position: relative; // 历史评定 xue
      font-size: 32rpx;
      color: #3d8ee4;
      font-weight: 700;
      display: flex;
      justify-content: center;
      align-items: center;
      .top-img {
        width: 40px;
        height: 40px;
        padding-right: 25px;
      }
      .top-hirEval {
        position: absolute;
        right: 3px;
        bottom: -9px;
        font-size: 10px;
        color: #3d8ee4e0;
      } // 历史评定 xue
    }
    .top-content {
      display: flex;
      flex-direction: row;
      justify-content: space-around;
      align-items: center;
      padding: 20px;
      .cont {
        display: flex;
        justify-content: center;
      }
      .txt-wen {
        color: #3d8ee4;
        font-size: 28rpx;
        font-weight: 400;
      }
      .txt-val {
        color: #3de48b;
        font-size: 34rpx;
        font-weight: 700;
      }
    }
    .footer-content {
      color: #3de48b;
      padding: 0 10px 10px 10px;
      display: flex;
      flex-wrap: wrap;
      flex-direction: row;
      .fot-arr {
        width: 50%;
      }
      .fot-arr:last-child {
        color: #d15070;
        .lvtxt {
          color: #d15070;
        }
        .footer-txt {
          background-color: rgba($color: #d15070, $alpha: 0.2);
        }
      }
      .footer-txt {
        padding: 18rpx;
        margin: 16rpx;
        background-color: rgba($color: #59e17b, $alpha: 0.2);
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: row;
        border-radius: 10px;
        word-wrap: break-word;
        word-break: normal;

        .top-img {
          width: 40px;
          height: 40px;
          padding-right: 26rpx;
        }
        .foot {
          display: flex;
          justify-content: center;
        }
        .txt-wen {
          font-size: 28rpx;
          font-weight: 400;
        }
        .txt-val {
          color: #333;
          font-size: 28rpx;
        }
        .lvtxt {
          color: #3de48b;
        }
      }
    }
    .fot-arr1 {
      .sub-title {
        margin: 36rpx 0;
        display: flex;
        justify-content: space-between;
        color: #3d8ee4;
        font-size: 31rpx;
        font-weight: 600;
        border-bottom: 2px solid #3d8ee4;
      }
      .cell-txt {
        line-height: 32rpx;
      }
    }
  }
}
</style>
